<template>
	<view>
		<u-input :value="time" :placeholder="placeholder"  disabled
			@click="handleTimeOpen" />
		<u-picker @confirm="onTimeConfirm" v-model="show" mode="time"></u-picker>
	</view>
</template>

<script>
	export default {
		props: {
			value: {
				type: String,
				default: ''
			},
			placeholder: {
				type: String,
				default: '请选择时间'
			},
			config: {
				type: Object,
				default: {}
			},
		},
		model: {
			prop: "value",
			event: "change"
		},
		computed: {
			time: {
				get() {
					return this.value;
				},
				set(val) {
					this.$emit('change', val);
				}
			}
		},
		data() {
			return {
				show: false,
			}
		},
		methods: {
			onTimeConfirm(item) {
				this.time = `${item.year}-${item.month}-${item.day}`
			},
			handleTimeOpen() {
				if(!this.config.disabled) this.show = true
			}
		}
	}
</script>

<style>
</style>